﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Domain.Repositories;
using YAPACS.BusinessObjects.Exams;

namespace YAPACS.RisServer.Controllers;

[Authorize]
[Route("/api/report-video-list")]
public class ReportVideoListController : AbpControllerBase
{
    private readonly IRepository<Report, Guid> _reportRepository;

    public ReportVideoListController(IRepository<Report, Guid> reportRepository)
    {
        _reportRepository = reportRepository;
    }

    [HttpGet("{reportId}/get-study-base-info")]
    public async Task<IActionResult> GetStudyBaseInfo(Guid reportId)
    {
        var report = await _reportRepository.GetAsync(reportId);
        var exam = report.Exam;
        return Ok(new
        {
            Success = true,
            Data = new
            {
                Id = exam.Id.ToString(),
                ReportId = report.Id.ToString(),
                StudyUID = exam.StudyInstanceUid,
                PatientName = exam.Patient.Name,
                DeviceTypeCode = exam.DeviceType.Code,
                Date = exam.CreationTime,
                exam.DeviceType.Modality,
                exam.Patient.PatientId,
                exam.AccessionNumber,
            }
        });
    }
}
